<?php
/**
 * Created by PhpStorm.
 * User: fengyan
 * Date: 17-11-3
 * Time: 下午4:51
 */

namespace App\Models\Basic;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Resource extends Model
{
    use SoftDeletes;

    protected $table = 'basic_resource';


    /**
     * 文档
     */
    public function document()
    {
        return $this->hasMany('\\App\\Models\\Portal\\Document', 'cover_id', 'id')->select(['id as obj_id', 'title as obj_title']);
    }

    /**
     * 栏目
     */
    public function category()
    {
        return $this->hasMany('\\App\\Models\\Portal\\Category', 'cover_id', 'id')->select(['id as obj_id', 'title as obj_title']);
    }

    /**
     * 友情链接
     */
    public function link()
    {
        return $this->hasMany('\\App\\Models\\Basic\\Link', 'cover_id', 'id')->select(['id as obj_id', 'title as obj_title']);
    }

    /**
     * 广告位默认封面图
     */
    public function adv()
    {
        return $this->hasMany('\\App\\Models\\Basic\\Adv', 'cover_id', 'id')->select(['id as obj_id', 'title as obj_title']);
    }

    /**
     * 广告图
     */
    public function advData()
    {
        return $this->hasMany('\\App\\Models\\Basic\\AdvData', 'cover_id', 'id')->select(['id as obj_id', 'title as obj_title']);
    }
}